home *** CD-ROM | disk | FTP | other *** search
- Path: howland.reston.ans.net!psinntp!psinntp!psinntp!psinntp!usenet
- From: grantp@usa.pipeline.com(Pete Grant)
- Newsgroups: comp.lang.c++,
- Subject: Re: MS VC++ 4.0 namespace weirdness
- Date: 28 Mar 1996 22:54:56 GMT
- Organization: Kalevi, Inc.
- Message-ID: <4jf5c0$dsr@news1.h1.usa.pipeline.com>
- References: <475745934wnr@ma.ccngroup.com>
- NNTP-Posting-Host: 38.8.120.15
- X-PipeUser: grantp
- X-PipeHub: usa.pipeline.com
- X-PipeGCOS: (Pete Grant)
- X-Newsreader: Pipeline v3.5.0
-
- On Mar 28, 1996 10:06:33 in article <Re: MS VC++ 4.0 namespace weirdness>,
- 'Alan Griffiths <aGriffiths@ma.ccngroup.com>' wrote:
-
-
- >In article: <4iq8up$hl3@news1.h1.usa.pipeline.com>
- >grantp@usa.pipeline.com(Pete Grant) writes:
- >>
- >> [snip]
- >> I have used namespace declarations inside header files, as in FOO1
- above,
- >> and have had no problems. The namespaces behave precisely as expected
- when
- >> compiled with MSVC++4.0/4.1.
- >
- >Then your expectation is wrong...
- >
- >#include <assert.h>
- >
- >namespace MyNamespace
- >{
- >int i = 1;
- >}
- >
- >int main()
- >{
- >int i = 2;
- >
- >using namespace MyNamespace;
- >
- >assert(2 == i); // fails with MSVC4
- >
- >return 0;
- >}
-
- If it's not too much trouble, could you cite the rule that makes
- MSVC wrong in he above sample. The way I read the draft, rule
- 7.3.4 seems to apply in this case. It says, in part,
- "A using-directive specifies that the names in the namespace ...
- can be used in the scope in which the using-directive appears
- .. exactly as if the names from the namespace had been declared
- outside the namespace at the points where the namespace was
- defined. ..."
-
- Now, the last part of the sentence is confusing, but seems to
- me that the name i is ambigous as it could be either unique::i
- or MyNamespace::i. Examples furnished in the draft appear to
- confirm this. Am I reading it wrong? Or is it just the case
- of local name vs. global?
-
- BTW, BC5 accepts the sample code using unique::i (the local one)
- so you are probably correct as Borland historically has been
- closer to the standard than Microsoft.
-
- --
- Pete Grant
- Kalevi, Inc.
- Software Engineering & development
-